package org.grayrabbit.cms.freemarker;

import javax.servlet.ServletContext;

import org.apache.struts2.views.freemarker.FreemarkerManager;
import org.grayrabbit.cms.freemarker.tpl.config.PopulateFtlData;
import org.springframework.context.ApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;


import freemarker.template.Configuration;
import freemarker.template.TemplateException;

public class FreemarkerManagerImpl extends FreemarkerManager {
	
	protected Configuration createConfiguration(ServletContext servletContext) throws TemplateException {  
		Configuration configuration = super.createConfiguration(servletContext);  
		
		ApplicationContext context = WebApplicationContextUtils.getRequiredWebApplicationContext( servletContext );
		PopulateFtlData.initFreemarkerConfiguration(context, configuration);
		
		return configuration;  
	}
}
